<include file="Public:script-load-page"/>
<body>
<div class="login"><img src="__PUBLIC__/Weixin/images/logo.png"></div>
<div style="width: 100%;text-align: right;">已有帐号？<a style="margin-right:4%;" href="{:U('login')}">立即登陆</a></div>

<div class="login_1">
	<form name="form1" id="form1" method="post">
		<ul>
			<!--地区-->
			<li style="color:#666;" class="login_line">
				<select class="province" id="province" name="province" style="float:left;margin-top:18px;margin-left:5px;">
					<volist name="province_list" id="vo">
						<option value="{$vo.region_code}" <?php if($vo['region_code']==36){ ?>selected='selected'<?php } ?>>{$vo.region_name}</option>
					</volist>
				</select>
				<select id="city" class="city" name="city" style="float:left;margin-top:18px;margin-left:5px;">
					<volist name="city_list" id="vo">
						<option value="{$vo.region_code}" <?php if($vo['region_code']==3601){ ?>selected='selected'<?php } ?>>{$vo.region_name}</option>
					</volist>
				</select>
				<select id="country" class="country" name="country" style="float:left;margin-top:18px;margin-left:5px;">
					<option>请选择</option>
					<volist name="country_list" id="vo">
						<option value="{$vo.region_code}">{$vo.region_name}</option>
					</volist>
				</select>
			</li>
			<li style="color:#666;width:100vw;overflow:hidden;" id="schoool" class="login_line" >
				<input class="login_input" id="school" name="school" placeholder="学校名称">
			</li>
			<li class="login_line">
				<select name="grade" class="s-1 live0_list" id="grade" style="float:left;margin-top:18px;margin-left:5px;color:#666666">
					<option value="0">请选择学龄段</option>
					<option value="学前">学前阶段</option>
					<option value="小学">小学阶段</option>
					<option value="初中">初中阶段</option>
					<option value="高中">高中阶段</option>
					<option value="其他">其他</option>
				</select>
				<select name="g_class" class="s-1 s_cl" id="g_class" style="float:left;margin-top:18px;margin-left:5px;color:#666666">
					<option value="0">请选择年级</option>
				</select>
			</li>
			<li class="login_line"><input class="login_input" name="s_class" id="s_class" placeholder="班级：例如“1班”则输入：1" value="" style="color:#666;" /></li>
			<li class="login_line"><input class="login_input" placeholder="真实姓名" id="s_name" name="s_name" value="" style="color:#666;" /></li>
			<li class="login_line"><img src="__PUBLIC__/Weixin/images/member.png">
				<input name="t_mobile" id="t_mobile" type="tel" class="login_input" value="" placeholder="手机号码" maxlength="11" style="color:#666;" /></li>

			<li class="login_line"><img src="__PUBLIC__/Weixin/images/passwords.png">
				<input name="t_password" id="t_password" type="password" class="login_input" value="" placeholder="密码" maxlength="20" style="color:#666;"></li>
			<li class="login_line"><img src="__PUBLIC__/Weixin/images/passwords.png">
				<input name="t_password" id="re_password" type="password" class="login_input" value="" placeholder="确认密码" maxlength="20" style="color:#666;"></li>
			<li class="login_line" ><img src="__PUBLIC__/Weixin/images/comment.png">
				<div style="width: 65%"><input class="login_input"  id="txtCode" name="mobile_verify" placeholder="请输入手机验证码" style="color:#666;" /></div>
				<div style="width: 32%;float: right"><button class="btn btn-primary" type="button" value="" style="background: orange;" sendsms="true">获取验证码</button></div></li>
		</ul>
		<label class="radio-inline">
			<input type="radio" name="identify" id="inlineRadio1" value="student" checked> 学生
		</label>
		<label class="radio-inline">
			<input type="radio" name="identify" id="inlineRadio2" value="teacher"> 老师
		</label>
		<span style="display:block;text-align:left;margin-top:10px;">
			为了确保你的账户信息安全及个人权益，请务必确认以上信息准确无误，否则责任自负。
		</span>
		<button class="login_but" type="button" name="btn_login" onclick="register();">注册</button>
	</form>
</div>
</body>
</html>
<script>
	$("#province").change(function(){
		$("#city").empty();
		$("#country").empty();
		$("#city").hide();
		$("#country").hide();
		var url="{:U('Public/region_tree')}";
		var data={region_code:$(this).val()};
		$.get(url,data,function(info){
			$.each(info[0],function(i,result){
				var city = "<option value="+result['region_code']+">"+result['region_name']+"</option>";
				$('#city').append(city);
			});
			$.each(info[1],function(i,result){
				var city = "<option value="+result['region_code']+">"+result['region_name']+"</option>";
				$('#country').append(city);
			});
			$('#city').show();
			$('#country').show();
		});
	});
	$("#city").change(function(){
		$("#country").empty();
		$("#country").hide();
		var url="{:U('Public/region_tree')}";
		var data={region_code:$(this).val()};
		$.get(url,data,function(info){
			$.each(info,function(i,result){
				var country = "<option value="+result['region_code']+">"+result['region_name']+"</option>";
				$('#country').append(country);
			});
			$('#country').show();
		})
	});
	var clea=function(){
		$("#school").remove();
		$("#cleea").remove();
		$("#schoool").append("<input class='login_input' id='school' name='school' placeholder='学校名称' />");
		$("#school").focus();
	};
	$("#country").change(function(){
		var url="{:U('Public/region_school')}";
		var data={region_code:$(this).val()};
		$.get(url,data,function(info){
			if(info !=false){
				$("#school").remove();
				$("#schoool").append("<select name='school' id='school'  style='float:left;margin-top:18px;margin-left:5px;width:70vw;overflow:hidden;'></select>" +
						"<button class='btn btn-primary' type='button' id='cleea' onclick='clea()' style='background: orange;'>手动输入</button>");
				$.each(info,function(i,result){
					var school = "<option value="+result['id']+">"+result['school_name']+"</option>";
					$('#school').append(school);
				});
				var school= "<option value="+0+">其他</option>";
				$("#school").append(school);
				$("#school").bind("change",function(){
					if($("#school").val() == 0){
						$("#school").remove();
						$("#schoool").append("<input class='login_input' id='school' name='school' placeholder='学校名称' />");
					}
				});
			}else{
				$("#school").remove();
				$("#schoool").append("<input class='login_input' id='school' name='school' placeholder='学校名称' />");
			}
		})
	});
//	$(function(){
//		if($.cookie("isremember")!=null&&$.cookie("isremember")!="")
//		{
//			var mobile=$.cookie("loginid");
//			var password=$.cookie("password");
//			if(mobile!=null&&mobile!="")
//				$("#t_mobile").val(mobile);
//			if(password!=null&&password!="")
//				$("#t_password").val(password);
//			$("#chk_isremember").attr("checked","checked");
//		}
//	});
$(function () {
	$(".live0_list").change(function () {
		var pid = $(this).val();
		var ss;
		switch (pid) {
			case "学前":
				ss = '<option value="0">请选择年级</option>' +
						'<option value="小班">小班</option>' +
						'<option value="中班">中班</option>' +
						'<option value="大班">大班</option>';
				break;
			case "小学":
				ss = '<option value="0">请选择年级</option>' +
						'<option value="1">一年级</option>' +
						'<option value="2">二年级</option>' +
						'<option value="3">三年级</option>' +
						'<option value="4">四年级</option>' +
						'<option value="5">五年级</option>' +
						'<option value="6">六年级</option>';
				break;
			case "初中":
				ss = '<option value="0">请选择年级</option>' +
						'<option value="初一">初一</option>' +
						'<option value="初二">初二</option>' +
						'<option value="初三">初三</option>';
				break;
			case "高中":
				ss = '<option value="0">请选择年级</option>' +
						'<option value="高一">高一</option>' +
						'<option value="高二">高二</option>' +
						'<option value="高三">高三</option>';
				break;
            case "其他":
            	ss = '<option value="其他">其他</option>';
					$("#s_class").val("其他");
				break;
			default:
				break;
		}
		$(".s_cl").html('');
		$(".s_cl").append(ss);
	})
});
	$('[sendsms]').click(function () {
		var obj = $(this);
		var phonet1 = /1[3-8]+\d{9}/;
		var phonet2 = /^([0-9]{11})?$/;
		var phone = $('#t_mobile').val();
		if(!phone || !phonet1.test(phone) || !phonet2.test(phone) ){
			myAlert("手机号格式不正确！");
//            layer.tips('手机号格式不正确！', '#input-newmobile');
			//setTimeout(function(){
			//  obj.html("发送短信");
			//}, 1000);
			return;
		}
		$.ajax({
			url: "{:U('ajax/sendsms')}",
			type: 'POST',
			dataType: 'json',
			data: {phone:phone},
			beforeSend:function (){
				obj.attr("disabled","disabled").html("发送中..");
			},
			success:function (data){
				if(data.status==0){
					var sum=60;
					setinTime=setInterval(function(){
						sum=sum-1;
						if(sum>0){
							obj.html(sum+"秒后重发");
						}else{
							obj.html("发送短信").removeAttr('disabled');
							clearInterval(setinTime);
						}
					},1000);
				}else{
					obj.html("发送短信").removeAttr('disabled');
					alert(data.info);
				}
			}
		})
	});
	function register()
	{
		var mobile=$("#t_mobile").val();
		var password=$("#t_password").val();
		var re_password=$("#re_password").val();
		var s_name=$("#s_name").val();
		if(!isMobile(mobile))
		{
			myAlert("请输入正确的手机号码");
			return false;
		}
		else if (password!=re_password){
			myAlert("两次密码输入不一致");
			return false;
		}
		else if(password.length<4||password.length>20)
		{
			myAlert("请输入规范的密码");
			return false;
		}else if(isNaN($("#country").val())){
			myAlert("请选择地址");
			return false;
		}else if($("#school").val() ==null || $("#school").val()==''){
			myAlert("请输入学校名称");
			return false;
		}else if($("#grade").val()==0 || $("#grade").val()==null ||$("#greade").val()==''){
			myAlert("请选择学龄段");
			return false;
		}else if($("#g_class").val()==0|| $("#g_class").val()==null ||$("#g_class").val()==''){
			myAlert("请选择年级");
			return false;
		}else if($("#s_class").val()==null ||$("#s_class").val()=='') {
			myAlert("请输入班级");
			return false;
		}
			if(!s_name){
			myAlert("请输入姓名");
			return false;
		}
		$("#form1").submit();
	}
</script>
